/*
 * @Author: Dorange.Wang
 * @Date: 2021-07-07 11:29:03
 * @LastEditors: your name
 * @LastEditTime: 2021-07-07 14:39:22
 * @Description: file content
 */
import { getHmuserMosconfig } from '@/apis/app/HmUserController'

const state = {
  enabled: false,
  domain: ''
}
const mutations = {
  setEnabled (state, payload) {
    state.enabled = payload
  },
  setDomain (state, payload) {
    state.domain = payload
  }
}
const actions = {
  async loadMosConfig ({ commit }) {
    const config = await getHmuserMosconfig()
    const { mosEnable: enabled, mosUrl: domain } = config
    commit('setEnabled', enabled)
    commit('setDomain', domain)
    return config
  }
}
const getters = {
  mosEnabled (state) {
    return state.enabled
  },
  mosDomain (state) {
    return state.domain
  }
}

export default {
  getters,
  state,
  mutations,
  actions
}
